/*
 * @Author: yayalee yangcheng960813@163.com
 * @Date: 2024-07-15 10:00:47
 * @LastEditTime: 2024-07-15 10:00:56
 * @LastEditors: yayalee yangcheng960813@163.com
 * @Description: 
 * @FilePath: \unfinished-challenges\assets\core_ts\Singleton.ts
 * 可以输入预定的版权声明、个性签名、空行等
 */

export default function Singleton<T>() {
    class SingletonE {
        protected constructor() {
        }

        protected static instance: SingletonE = null!;

        public static get ins(): T {
            if (SingletonE.instance == null) {
                SingletonE.instance = new this();
            }
            return SingletonE.instance as T;
        }
    }

    return SingletonE;
}